<!-- 顶部导航条 -->
<template>
  <div class="nav-bar">
    <div class="left">
      <slot name="left"><van-icon name="arrow-left" @click="goback" /></slot>
    </div>
    <div class="center"><slot name="center">EWshop</slot></div>
    <div class="right"><slot name="right"></slot></div>
  </div>
</template>

<script>
import { Icon } from "vant";
import { useRouter } from "vue-router";
export default {
  name: "NavBar",
  setup() {
    const router = useRouter();
    const goback = () => {
      router.go(-1);
    };
    return {
      goback,
    };
  },
  components: {
    [Icon.name]: Icon,
  },
};
</script>

<style>
.nav-bar {
  background-color: aquamarine;
  color: #ffffff;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 9;
  height: 45px;
  line-height: 45px;
  text-align: center;
  box-shadow: 0 2px 0px rgba(100, 100, 100, 0.1);
  display: flex;
}
.left,
.right {
  width: 60px;
}

.left img {
  width: 45px;
  padding: 12px;
}
.center {
  flex: 1;
}
</style>